<?php
class Form{
	private $fields = array();
	private $button;
	private $location;
	function addField($type, $label, $value=""){
		$this->fields[] = array($type, $label, $value);
	}
	function button($value, $location=""){
		$this->button = $value;
		$this->location = $location;
	}
	function draw($labelWidth="100px"){
		echo "<div class=\"form-container\">";
		foreach($this->fields as $field){
			if($field[0] == "text"){
				echo "<div><label>$field[1]</label><input type=\"text\" value=\"$field[2]\"/></div>";			
			}
			if($field[0] == "date"){
				echo "<div><label>$field[1]</label><input style=\"width:100px;\" type=\"text\" value=\"$field[2]\"/></div>";			
			}
			if($field[0] == "dollar"){
				echo "<div><label>$field[1]</label><input type=\"text\" value=\"$ $field[2]\"/></div>";			
			}
			if($field[0] == "combo"){
				echo "<div><label>$field[1]</label><input type=\"checkbox\" value=\"$field[2]\"/></div>";	
			}
			if($field[0] == "video"){
				echo "<div><label>$field[1]</label><div class=\"field-container\"><object width=\"192\" height=\"154\"><param name=\"movie\" value=\"http://www.youtube.com/v/okEPMABxkQE?fs=1&amp;hl=en_GB\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/okEPMABxkQE?fs=1&amp;hl=en_GB\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"192\" height=\"154\"></embed></object><div style=\"padding-top:5px;\"><input type=\"text\" value=\"http://www.youtube.com/v/okEPMABxkQE?fs=1&amp;hl=en_GB\"></div></div></div>";	
			}
			if($field[0] == "photo"){
				echo "<div><label>$field[1]</label><div class=\"field-container\"><img width=\"230px\" height=\"150px\" src=\"../assets/img/img_auction_item_04.png\"/><div style=\"padding-top:5px;\"><input type=\"file\"></div></div></div>";	
			}
			if($field[0] == "type"){
				echo "<div><label>$field[1]</label><select><option>Part</option><option>Consumable</option></select></div>";			
			}
			if($field[0] == "select"){
				$iselect = "<option>Select...</option>";
				if((isset($field[2]) && ($field[2] != "")))
					$iselect = "<option>$field[2]</option>";
				echo "<div><label>$field[1]</label><select>$iselect<option>Options listed here</option></select></div>";			
			}
		}
		echo "<div><label>&nbsp;</label><a href=\"".$this->location."\" class=\"bt btn_save\">".$this->button."</a></div>";
		echo "</div>";
	}
}